Skip to content

feat: add content_format option to get_emails_content#106

Open
jkp wants to merge 3 commits intoai-zerolab:mainfrom
jkp:feat/content-format-option
Open

feat: add content_format option to get_emails_content#106
jkp wants to merge 3 commits intoai-zerolab:mainfrom
jkp:feat/content-format-option

Conversation

@jkp
Copy link

@jkp jkp commented Jan 17, 2026

Summary

  • Add content_format parameter to get_emails_content to control how email body content is formatted
  • Support four formats: raw (default), html, text, and markdown
  • Extract both plain text and HTML body parts from emails for flexible formatting
  • Use justhtml library for HTML-to-text and HTML-to-markdown conversion

Motivation

When processing emails programmatically, raw HTML content can be difficult to work with. This feature allows extracting clean text from HTML emails, making content easier to process.

API Changes

get_emails_content(
    account_name: str,
    email_ids: list[str],
    mailbox: str = "INBOX",
    content_format: str = "raw"  # NEW: "raw" | "html" | "text" | "markdown"
)

Test plan

  • Unit tests for _format_body_content helper function (9 tests)
  • Tests for _parse_email_data extracting HTML content (3 tests)
  • MCP tool tests with different content_format values (3 tests)
  • All existing tests pass (125 total)

🤖 Generated with Claude Code

Jamie Kirkpatrick and others added 2 commits January 17, 2026 11:50
Add a content_format parameter to extract clean text from HTML emails:
- "raw" (default): text/plain preferred, falls back to HTML
- "html": return HTML content as-is
- "text": strip HTML tags to return clean plain text
- "markdown": convert HTML to markdown format

Uses justhtml library for HTML parsing and conversion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

❌ Patch coverage is 87.23404% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mcp_email_server/emails/classic.py 82.8% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

- Add default_content_format to Settings class (defaults to "raw")
- Support MCP_EMAIL_SERVER_DEFAULT_CONTENT_FORMAT env var
- Validate content format values (raw, html, text, markdown)
- Update get_emails_content to use setting when format not specified
- Add tests for new configuration option
- Update README with configuration documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Wh1isper
Copy link
Member

Looks good. Can you resolve the conflict?

@Wh1isper Wh1isper self-assigned this Jan 19, 2026
@Wh1isper
Copy link
Member

Looks good. Can you resolve the conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants